		function addzero(add){
				if(add < 10 && add > 0){
					add = '0'+add;
				}
				return add;
			}
			$(function(){
				$.post("docheck.php","",function(d){
					if(d.login){
						$('body').addClass('text-center').html('你已经登录！<br />2秒钟后进入主页！');
						setTimeout(function(){window.location.href="home.html";},2000);
					}
				},"json");
				$.ms_DatePicker({
                    YearSelector: "#select_year",
                    MonthSelector: "#select_month",
                    DaySelector: "#select_day"
                });
				$('#registe').attr('data-placement', 'left');
				$('#registe').attr('title', '注册');
				$('#registe').popover();
				function checkbirthday(){
					if($('#select_year').val() == 0 || $('#select_month').val() == 0 || $('#select_day').val() == 0){
						var el = $('.date');
						if (el.data('bs.popover')) {
							el.data('bs.popover').options.content = "请选择正确的日期";
							el.data('bs.popover').options.container = 'body';
						}
						else {
							el.popover({
								placement: 'right',
								trigger: 'manual',
								container: 'body',
								content: "请选择正确的日期"
							});
						}
						el.popover('show');
						return false;
					}
					else{
						$('.date').popover('hide');						
						return true;
					}
				}
				
				function checkaddr(){
					if($('#seachprov').val() == 0 || $('#seachcity').val() == 0 || $('#seachdistrict').val() == 0){
						var el = $('.addr');
						if (el.data('bs.popover')) {
							el.data('bs.popover').options.content = "请选择正确的地址";
							el.data('bs.popover').options.container = 'body';
						}
						else {
							el.popover({
								placement: 'right',
								trigger: 'manual',
								container: 'body',
								content: "请选择正确的地址"
							});
						}
						el.popover('show');
						return false;
					}
					else{
						$('.addr').popover('hide');
						return true;
					}
				}
				
				$.post("docheck.php","",function(d){
					if(d.login){
						alert(d.msg);
					}
				},"json");
				$('#img_code').click(function(){
					$('#img_code').attr('src','identifying_code.php');
				});
				$('#a_code').click(function(){
					$('#img_code').attr('src','identifying_code.php');
					return false;
				});
				$('#u_registe').validate({
					rules:{
						name:{
							userName:true,
							remote: {
								url: 'check_username.php',
								type: 'post',
								data: {
									name: function(){
										return $('#name').val();
									}
								}
							}
						},
						pwd:{
							isPwd:true
						},
						re_pwd:{
							equalTo:"#pwd"
						},
						re_name:{
							reName:true
						},
						email:{
							email:true
						},
						phone:{
							isMobile:true
						}
					},
					focusInvalid: false,
					onkeyup: false,
					messages:{
						name:{
							required:"请输入用户名",
							remote:"该用户名已经存在"
						},
						pwd:{
							required:"请输入密码",
						},
						re_name:{
							required:"请输入真实姓名"
						},
						phone:{
							required:"请输入你的手机号码",
							isMobile:"请输入正确的手机号码"
						},
						re_pwd:{
							required:"请确认密码",
							equalTo:"密码不同，请确认密码"
						},
						select_year:{
							digits:"请选择正确的年份"
						},
						select_month:{
							digits:"请选择正确的月份"
						},
						select_day:{
							digits:"请选择正确的日期"
						},
						check_code:{
							required:"请输入验证码"
						},
						addr:{
							required:"请输入详细地址"
						},
						email:"请输入电子邮箱地址"
					},
					showErrors: function(){
						for (var i = 0, e, el; e = this.errorList[i++];) {
							el = $(e.element);
							if (el.data('bs.popover')) {
								el.data('bs.popover').options.content = e.message;
								el.data('bs.popover').options.container = 'body';
							}
							else {
								el.popover({
									placement: 'right',
									trigger: 'manual',
									container: 'body',
									content: e.message
								});
							}
							el.popover('show');
						}
						for (var i = 0, s, el; s = this.successList[i++];) {
							el = $(s);
							el.popover('hide');
						}
					}
				});
				initComplexArea('seachprov', 'seachcity', 'seachdistrict', area_array, sub_array, '51', '0', '0');
				$('#registe').click(function(){
					
					
					if ($('#u_registe').valid() && checkbirthday() && checkaddr()){
						var birthday = $('#select_year').val() + "-" +addzero($('#select_month').val()) +"-"+ addzero($('#select_day').val());
						$.post("registe.php",{
							'name':$('#name').val(),
							'pwd':$.md5($('#pwd').val()),
							're_name':$('#re_name').val(),
							'sex':$('#sex').val(),
							'birthday':birthday,
							'phone':$('#phone').val(),
							'tel':$('#tel').val(),
							'qq':$('#qq').val(),
							'addrcode':$('#seachdistrict').val(),
							'addr':$('#addr').val(),
							'email':$('#email').val(),
							'check_code':$('#check_code').val()
						},function(d){
							$('#img_code').attr('src','identifying_code.php');
							$('#registe').attr('data-content', d.msg);
							$('#registe').popover('show');
							if(d.success){
								setTimeout(function(){
									window.location.assign("home.html");
								},1500);
							}else{
								$('#img_code').attr('src','identifying_code.php');
								setTimeout(function(){
									$('#registe').popover('hide');
								},1500);
							}
						},"json");
					}
					return false;					
				});
				
			});